Filter statuses only by the relevant path
authorAlex Crichton <alex@alexcrichton.com>
Thu, 25 Jun 2015 06:56:59 +0000 (23:56 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 25 Jun 2015 06:59:03 +0000 (23:59 -0700)
This enables libgit2 to not traverse the majority of the tree, saving a lot of
otherwise unnecessary syscalls.

src/cargo/sources/path.rs

index 80f9195420a5ed6387601ba3d6479fbdf0906821..0e3668b42b4a2063dad13bdf48fd977b1abfdbd0 100644 (file)
@@ -153,6 +153,9 @@ impl<'cfg> PathSource<'cfg> {
         });
         let mut opts = git2::StatusOptions::new();
         opts.include_untracked(true);
+        if let Some(suffix) = util::without_prefix(pkg_path, &root) {
+            opts.pathspec(suffix);
+        }
         let statuses = try!(repo.statuses(Some(&mut opts)));
         let untracked = statuses.iter().map(|entry| {
             (join(&root, entry.path_bytes()), None)